package com.ncepu.clubmanagement.mapper;

import com.ncepu.clubmanagement.pojo.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MultiMediaMapper {
    @Insert("insert into multimedia( club_id, person_id, title, cover_url, multimedia_url, suggested,type) " +
            "values(#{clubId}, #{personId}, #{title}, #{coverUrl}, #{multiMediaUrl}, #{suggested},#{type})")
    @Options(useGeneratedKeys = true, keyProperty = "multimediaId")
    void insertMultiMedia(MultiMedia multiMedia);


    @Update("update multimedia set cover_url = #{url} where multimedia_id = #{multimediaId}")
    void updateCoverUrl(String url, Integer multimediaId);

    @Update("update multimedia set multimedia_url = #{url} where multimedia_id = #{multimediaId}")
    void updateMultiMediaUrl(String url, Integer multimediaId);

    void updateMultiMediaWithoutUpdateURL(MultiMediaChangeableInfo mediaChangeableInfo);

    @Select("select club_id from multimedia where multimedia_id = #{value6}")
    Integer selectClubIdByMultiMediaId(Integer value6);


    MultiMediaFontOfGet selectMultiMediaFontOfGetByMultiMediaId(Integer multiMediaId);


    List<MultiMediaFontOfGetInList> selectMultiMediaFontOfGetInList(Integer personId);

    @Select("select EXISTS(select 1 from multimedia where person_id = #{personId} and multimedia_id = #{multiMediaId})")
    boolean isPersonIdAndMultiMediaIdExist(Integer personId, Integer multiMediaId);

    @Select("select * from multimedia where multimedia_id = #{multiMediaId}")
    MultiMedia selectMultiMediaByMultiMediaId(Integer multiMediaId);

    @Delete("delete from multimedia where multimedia_id = #{multiMediaId}")
    void deleteByMultiMediaId(Integer multiMediaId);

    @Update("update multimedia set suggested = #{isSuggested} where multimedia_id = #{multiMediaId}")
    void updateSuggestStatusByIsSuggested(Integer isSuggested, Integer multiMediaId);

    List<MultiMediaFontOfGetInHead> selectMultiMediaFontOfGetInStyle(Integer clubId);

    List<MultiMediaFontOfGetInHead> selectMultiMediaFontOfGetInHeadImage(Integer needNum, int type);
}
